﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Data;
using System.Globalization;

namespace BadHabit.Factory.Converters {

    [ValueConversion(typeof(object), typeof(int))]
    public class TaskImageConverter : IValueConverter {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {

            if (value == null)
                return 1;

            DateTime date = (DateTime)value;        

            TimeSpan diff = date.Subtract(DateTime.Now);

            if (diff.Days < 0)
                return 3;

            if (diff.Days >= 5)
                return 1;
            
            return 2;


        }


        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            return new NotSupportedException();
        }
    }
}